//
//  GWMainTabbarController.m
//  百思不得姐
//
//  Created by qianfeng on 16/3/1.
//  Copyright (c) 2016年 高炜. All rights reserved.
//

#import "GWMainTabbarController.h"
#import "GWEssenceViewController.h"
#import "GWFriendViewController.h"
#import "GWNewViewController.h"
#import "GWMeViewController.h"
#import "GWMyTabBar.h"
#import "GWMyNavigationController.h"
@interface GWMainTabbarController ()

@end

@implementation GWMainTabbarController

+(void)initialize
{
    
    UITabBarItem *item =[UITabBarItem appearance];
    [item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor grayColor]} forState:UIControlStateNormal];
    [item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor darkGrayColor]} forState:UIControlStateSelected];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self setUpVC];
    GWMyTabBar *tabBar =[[GWMyTabBar alloc]init];
    [self setValue:tabBar forKey:@"tabBar"];
}
-(void)setUpVC
{
    GWEssenceViewController *vc1 =[[GWEssenceViewController alloc]init];
    [self setUpVC:vc1 WithIcon:@"tabBar_essence_icon" SelectedIcon:@"tabBar_essence_click_icon" title:@"精华"];
    
    GWNewViewController *vc2 =[[GWNewViewController alloc]init];
    [self setUpVC:vc2 WithIcon:@"tabBar_new_icon" SelectedIcon:@"tabBar_new_click_icon" title:@"新帖"];
    
    GWFriendViewController *vc3 =[[GWFriendViewController alloc]init];
    [self setUpVC:vc3 WithIcon:@"tabBar_friendTrends_icon" SelectedIcon:@"tabBar_friendTrends_click_icon" title:@"关注"];
    
    GWMeViewController *vc4 =[[GWMeViewController alloc]initWithStyle:UITableViewStyleGrouped];
    [self setUpVC:vc4 WithIcon:@"tabBar_me_icon" SelectedIcon:@"tabBar_me_click_icon" title:@"我"];
}
-(void)setUpVC:(UIViewController *)VC WithIcon:(NSString *)icon SelectedIcon:(NSString *)selectedIcon title:(NSString *)title
{
    VC.tabBarItem.image =[UIImage imageNamed:icon];
    VC.tabBarItem.selectedImage =[UIImage imageNamed:selectedIcon];
    VC.tabBarItem.title =title;
    GWMyNavigationController *nvc =[[GWMyNavigationController alloc]initWithRootViewController:VC];
    
    [self addChildViewController:nvc];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
